<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Tacopie: tacopie::io_service Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="tacopie_logo.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Tacopie
   &#160;<span id="projectnumber">3.0.0</span>
   </div>
   <div id="projectbrief">Tacopie is a TCP Client &amp; Server C++11 library.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>tacopie</b></li><li class="navelem"><a class="el" href="classtacopie_1_1io__service.html">io_service</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classtacopie_1_1io__service-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">tacopie::io_service Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="io__service_8hpp_source.html">io_service.hpp</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:abb66850c32d9c724f4418d77bd04bcfd"><td class="memItemLeft" align="right" valign="top">typedef std::function&lt; void(fd_t)&gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">event_callback_t</a></td></tr>
<tr class="separator:abb66850c32d9c724f4418d77bd04bcfd"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a4cd4a873cb4457cdc28bd2d00665d15a"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#a4cd4a873cb4457cdc28bd2d00665d15a">io_service</a> (void)</td></tr>
<tr class="separator:a4cd4a873cb4457cdc28bd2d00665d15a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae423d7e4b13f07fe41fb051345ffbf8d"><td class="memItemLeft" align="right" valign="top"><a id="ae423d7e4b13f07fe41fb051345ffbf8d"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#ae423d7e4b13f07fe41fb051345ffbf8d">~io_service</a> (void)</td></tr>
<tr class="memdesc:ae423d7e4b13f07fe41fb051345ffbf8d"><td class="mdescLeft">&#160;</td><td class="mdescRight">dtor <br /></td></tr>
<tr class="separator:ae423d7e4b13f07fe41fb051345ffbf8d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad5da7503d8fec083c6d28455ec9e21c7"><td class="memItemLeft" align="right" valign="top"><a id="ad5da7503d8fec083c6d28455ec9e21c7"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#ad5da7503d8fec083c6d28455ec9e21c7">io_service</a> (const <a class="el" href="classtacopie_1_1io__service.html">io_service</a> &amp;)=delete</td></tr>
<tr class="memdesc:ad5da7503d8fec083c6d28455ec9e21c7"><td class="mdescLeft">&#160;</td><td class="mdescRight">copy ctor <br /></td></tr>
<tr class="separator:ad5da7503d8fec083c6d28455ec9e21c7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a980652008516b38357d405c16eda07fa"><td class="memItemLeft" align="right" valign="top"><a id="a980652008516b38357d405c16eda07fa"></a>
<a class="el" href="classtacopie_1_1io__service.html">io_service</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#a980652008516b38357d405c16eda07fa">operator=</a> (const <a class="el" href="classtacopie_1_1io__service.html">io_service</a> &amp;)=delete</td></tr>
<tr class="memdesc:a980652008516b38357d405c16eda07fa"><td class="mdescLeft">&#160;</td><td class="mdescRight">assignment operator <br /></td></tr>
<tr class="separator:a980652008516b38357d405c16eda07fa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7e2b0700c0a4591f86c344df8748b3a5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#a7e2b0700c0a4591f86c344df8748b3a5">set_nb_workers</a> (std::size_t nb_threads)</td></tr>
<tr class="separator:a7e2b0700c0a4591f86c344df8748b3a5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9f4c8bce3c0f6d660515b0b5eb109df8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#a9f4c8bce3c0f6d660515b0b5eb109df8">track</a> (const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;socket, const <a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">event_callback_t</a> &amp;rd_callback=nullptr, const <a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">event_callback_t</a> &amp;wr_callback=nullptr)</td></tr>
<tr class="separator:a9f4c8bce3c0f6d660515b0b5eb109df8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8094c1fec76c6821cc0c008fe524c89a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#a8094c1fec76c6821cc0c008fe524c89a">set_rd_callback</a> (const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;socket, const <a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">event_callback_t</a> &amp;event_callback)</td></tr>
<tr class="separator:a8094c1fec76c6821cc0c008fe524c89a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7c4f56c7790c7ba52b09837a42aaffb1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#a7c4f56c7790c7ba52b09837a42aaffb1">set_wr_callback</a> (const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;socket, const <a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">event_callback_t</a> &amp;event_callback)</td></tr>
<tr class="separator:a7c4f56c7790c7ba52b09837a42aaffb1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9a7672f0894a0fc1a3e6c593ca6df22c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#a9a7672f0894a0fc1a3e6c593ca6df22c">untrack</a> (const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;socket)</td></tr>
<tr class="separator:a9a7672f0894a0fc1a3e6c593ca6df22c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa57db619baeaa6db0aeb22e67b895cd7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classtacopie_1_1io__service.html#aa57db619baeaa6db0aeb22e67b895cd7">wait_for_removal</a> (const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;socket)</td></tr>
<tr class="separator:aa57db619baeaa6db0aeb22e67b895cd7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>service that operates IO Handling. It polls sockets for input and output, processes read and write operations and calls the appropriate callbacks. </p>
</div><h2 class="groupheader">Member Typedef Documentation</h2>
<a id="abb66850c32d9c724f4418d77bd04bcfd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abb66850c32d9c724f4418d77bd04bcfd">&#9670;&nbsp;</a></span>event_callback_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef std::function&lt;void(fd_t)&gt; <a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">tacopie::io_service::event_callback_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>callback handler typedef called on new socket event if register to <a class="el" href="classtacopie_1_1io__service.html">io_service</a> </p>

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a4cd4a873cb4457cdc28bd2d00665d15a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4cd4a873cb4457cdc28bd2d00665d15a">&#9670;&nbsp;</a></span>io_service()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">tacopie::io_service::io_service </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>ctor </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a7e2b0700c0a4591f86c344df8748b3a5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7e2b0700c0a4591f86c344df8748b3a5">&#9670;&nbsp;</a></span>set_nb_workers()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void tacopie::io_service::set_nb_workers </td>
          <td>(</td>
          <td class="paramtype">std::size_t&#160;</td>
          <td class="paramname"><em>nb_threads</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>reset number of <a class="el" href="classtacopie_1_1io__service.html">io_service</a> workers assigned to this <a class="el" href="classtacopie_1_1io__service.html">io_service</a> this can be safely called at runtime, even if the <a class="el" href="classtacopie_1_1io__service.html">io_service</a> is currently running it can be useful if you need to re-adjust the number of workers</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">nb_threads</td><td>number of workers </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a8094c1fec76c6821cc0c008fe524c89a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8094c1fec76c6821cc0c008fe524c89a">&#9670;&nbsp;</a></span>set_rd_callback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void tacopie::io_service::set_rd_callback </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;&#160;</td>
          <td class="paramname"><em>socket</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">event_callback_t</a> &amp;&#160;</td>
          <td class="paramname"><em>event_callback</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>update the read callback if socket is not tracked yet, track it</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">socket</td><td>socket to be tracked </td></tr>
    <tr><td class="paramname">event_callback</td><td>callback to be executed on read event </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a7c4f56c7790c7ba52b09837a42aaffb1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7c4f56c7790c7ba52b09837a42aaffb1">&#9670;&nbsp;</a></span>set_wr_callback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void tacopie::io_service::set_wr_callback </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;&#160;</td>
          <td class="paramname"><em>socket</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">event_callback_t</a> &amp;&#160;</td>
          <td class="paramname"><em>event_callback</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>update the write callback if socket is not tracked yet, track it</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">socket</td><td>socket to be tracked </td></tr>
    <tr><td class="paramname">event_callback</td><td>callback to be executed on write event </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a9f4c8bce3c0f6d660515b0b5eb109df8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9f4c8bce3c0f6d660515b0b5eb109df8">&#9670;&nbsp;</a></span>track()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void tacopie::io_service::track </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;&#160;</td>
          <td class="paramname"><em>socket</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">event_callback_t</a> &amp;&#160;</td>
          <td class="paramname"><em>rd_callback</em> = <code>nullptr</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classtacopie_1_1io__service.html#abb66850c32d9c724f4418d77bd04bcfd">event_callback_t</a> &amp;&#160;</td>
          <td class="paramname"><em>wr_callback</em> = <code>nullptr</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>track socket add socket to <a class="el" href="classtacopie_1_1io__service.html">io_service</a> tracking for read/write operation socket is polled only if read or write callback is defined</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">socket</td><td>socket to be tracked </td></tr>
    <tr><td class="paramname">rd_callback</td><td>callback to be executed on read event </td></tr>
    <tr><td class="paramname">wr_callback</td><td>callback to be executed on write event </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a9a7672f0894a0fc1a3e6c593ca6df22c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9a7672f0894a0fc1a3e6c593ca6df22c">&#9670;&nbsp;</a></span>untrack()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void tacopie::io_service::untrack </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;&#160;</td>
          <td class="paramname"><em>socket</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>remove socket from <a class="el" href="classtacopie_1_1io__service.html">io_service</a> tracking socket is marked for untracking and will effectively be removed asynchronously from tracking once</p><ul>
<li>poll wakes up</li>
<li>no callback are being executed for that socket</li>
</ul>
<p>re-adding track while socket is pending for untrack is fine and will simply cancel the untrack operation</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">socket</td><td>socket to be untracked </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aa57db619baeaa6db0aeb22e67b895cd7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa57db619baeaa6db0aeb22e67b895cd7">&#9670;&nbsp;</a></span>wait_for_removal()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void tacopie::io_service::wait_for_removal </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classtacopie_1_1tcp__socket.html">tcp_socket</a> &amp;&#160;</td>
          <td class="paramname"><em>socket</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>wait until the socket has been effectively removed basically wait until all pending callbacks are executed</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">socket</td><td>socket to wait for </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>includes/tacopie/network/<a class="el" href="io__service_8hpp_source.html">io_service.hpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
